﻿//------------------------------------------------------------------------------
// <copyright file="IExceptionFactory.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//------------------------------------------------------------------------------

namespace Microsoft.Internal.GamesTest.Rpc.Client
{
    using System;

    /// <summary>
    /// Interface that should be implemented to translate user-defined error codes into exceptions.
    /// </summary>
    public interface IExceptionFactory
    {
        /// <summary>
        /// Method should be implemented in derived class to map user-defined error codes to exceptions.
        /// This method will be called whenever a user-defined remote method is invoked and returns.
        /// </summary>
        /// <param name="methodName">Name of the invoked method.</param>
        /// <param name="errorCode">Error code returned by remote method.</param>
        /// <param name="input">Request parameters sent to the server.</param>
        /// <param name="output">Output sent back by the server.</param>
        /// <returns>The mapped Exception. Recommended to return <c>null</c> if an Exception couldn't be mapped.</returns>
        Exception CreateExceptionForErrorCode(string methodName, RpcHookCode errorCode, RpcArchive input, RpcArchive output);
    }
}
